home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Language / Compiler / Builtins / phoney_NodeList.m < prev    next >
Text File  |  1990-08-16  |  2KB  |  70 lines

  1. % @(#)phoney_NodeList.X    1.1  3/16/88
  2. %
  3. import _NodeListElementObject from "Builtins"
  4. export _NodeListObject to "Builtins"
  5.  
  6. const _NodeListObject == immutable object _NodeListObject
  7.   export getSignature, create
  8.  
  9.   const NodeListType ==    type NodeListType
  10.     function  getElement [Integer] -> [_NodeListElementObject]
  11.     operation setElement [Integer, _NodeListElementObject]
  12.     function  upperbound -> [Integer]
  13.     function  lowerbound -> [Integer]
  14.     function  getSlice [Integer, Integer] -> [NodeListType]
  15.     operation setSlice [Integer, Integer, NodeListType]
  16.     operation catenate [a : NodeListType] -> [r : NodeListType]
  17.   end NodeListType
  18.  
  19.   function getSignature -> [result : Signature]
  20.     result <- NodeListType
  21.   end getSignature
  22.  
  23.   operation create[length : Integer] -> [result : NodeListType]
  24.     result <-
  25.       object aNodeList
  26.     export getElement, setElement, upperbound, lowerbound,
  27.           getSlice, setSlice, catenate
  28.  
  29.     function  getElement [index : Integer] -> [result : _NodeListElementObject]
  30.       % get the element indexed by index, failing if index 
  31.       % out of range.
  32.       primitive 012 [result] <- [index]
  33.     end getElement
  34.     operation setElement [index : Integer, e : _NodeListElementObject]
  35.       % set the element, failing if index out of range
  36.       primitive 112 [] <- [index, e]
  37.     end setElement
  38.     function  upperbound -> [r : Integer]
  39.       % return the highest valid index, ub.
  40.       primitive 212 [r] <- []
  41.     end upperbound
  42.     function  lowerbound -> [r : Integer]
  43.       % return the lowest valid index, always 1.
  44.       primitive 312 [r] <- []
  45.     end lowerbound
  46.     function  getSlice [i1 : Integer, length : Integer] -> [r : NodeListType]
  47.       % return a new Vector, a, with lower bound 0, and 
  48.       % upper bound length-1, such that for 0 <= i < length:
  49.       %     self.getElement[i1+i] == a.getElement[i]
  50.       % fail if i1 or i1+length is out of range.
  51.       primitive 412 [r] <- [i1, length]
  52.     end getSlice
  53.     operation setSlice [i1 : Integer, length : Integer, e : NodeListType]
  54.       % set the elements indexed by i for i1 <= i < i1+length, so 
  55.       % that for each such i:
  56.       %     self.getElement[i1+i] == a.getElement[i]
  57.       % fail if i1 or i1+length is out of range.
  58.       primitive 512 [] <- [i1, length, e]
  59.     end setSlice
  60.     operation catenate [a : NodeListType] -> [r : NodeListType]
  61.       % return a new vector the result of catenating the 
  62.       % elements of a to self
  63.       primitive 612 [r] <- [a]
  64.     end catenate
  65.       end aNodeList
  66.   end create
  67. end _NodeListObject
  68.  
  69.